home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts6-06
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: Initializing an Array of Strings
- Date: Sat, 09 Mar 96 20:25:08 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4hspfg$rsm@sam.inforamp.net>
- References: <31409559.1FC6@enigma.vcr.esltd.com>
- NNTP-Posting-Host: ts6-06.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <31409559.1FC6@enigma.vcr.esltd.com>,
- Eric Kolotyluk <eric@enigma.vcr.esltd.com> wrote:
- >Please reply to eric@enigma.vcr.esltd.com
- >
- > char* errorName[];
- >Is there something basically wrong with what I'm trying to do?
- >I just don't see what the problem is with the definition of errorName.
- >Also, is there a way to initialize something with an array of strings?
-
- In most cases, you cannot initial an array without telling the compiling what
- the size. Some people use the notation
-
- char erroName[]={"Randy"};
-
- ..but the length is implicitly implied.
- I'm assuming that you want an array of strings.
- Thus you should use...
-
- char ** errorName;
-
- ..but the code would be cumbersome.
- The best thing to do is use a container class and an C++ string class.
-
- MFC has a great container class called CArrayString (or something like that)
- that is an array of CString's. OWL has a class called TArrayAsVector that can
- be extended (very very easily) to be an array of String's. CString and String
- are encapsulation of a character strings. They are very powerful.
-
- If you don't have access to a container class and a C++ string class, then I
- suggest you give yourself access to one, by finding one or writing one.
- They'll save you endless amounts of time. I need to parse a CString (MFC) and
- simply extended CString by adding more << operators. Saved me hours of time.
-
- Agrivar
-